package beerAir;

import java.util.Calendar;
import java.util.Date;

import javax.persistence.*;
import javax.validation.constraints.*;

@Entity
public class User {

	@Id
	@NotNull
	private String idDoc;
	
	@Temporal(TemporalType.TIMESTAMP)
	@NotNull
	private Date expDate;
	
	@NotNull
	private String baggage;
	
	@NotNull
	private String firstName;
	
	@NotNull
	private String secondName;
	
	@Temporal(TemporalType.TIMESTAMP)
	@NotNull
	private Date birthDate;
	
	@NotNull
	private String docType;

	public boolean checkDoc(String docType, String docNum){
		if(docType.equals(null) || docNum.equals(null))
			return false;
		switch (docType) {
		
		case "idcard":
				if(docNum.length()==7)
					return true;
		break;
			
		case "passport":
			if(docNum.length()==10)
				return true;
		break;
		
		}
		return false;
	}
	
	public boolean checkExp(Date docExp){
		if(docExp==null){
			return false;
		}
		Date today = Calendar.getInstance().getTime();
		if(docExp.before(today))
			return false;
		
		return true;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getSecondName() {
		return secondName;
	}

	public void setSecondName(String secondName) {
		this.secondName = secondName;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public String getDocType() {
		return docType;
	}

	public void setDocType(String docType) {
		this.docType = docType;
	}

	public String getIdDoc() {
		return idDoc;
	}

	public void setIdDoc(String idDoc) {
		this.idDoc = idDoc;
	}

	public Date getExpDate() {
		return expDate;
	}

	public void setExpDate(Date expDate) {
		this.expDate = expDate;
	}

	public String getBaggage() {
		return baggage;
	}

	public void setBaggage(String baggage) {
		this.baggage = baggage;
	}
}